<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('学生申请岗位列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
<!--                            <li>-->
<!--                                <label>学生id：</label>-->
<!--                                <input type="text" name="userId"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>岗位id：</label>-->
<!--                                <input type="text" name="postId"/>-->
<!--                            </li>-->
                            <li>
                                <label>状态：</label>
                                <select name="status" th:with="type=${@dict.getType('workstudy_post_user_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="workstudy:post_user:add">
                    <i class="fa fa-plus"></i> 申请岗位
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="workstudy:post_user:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="workstudy:post_user:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="workstudy:post_user:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('workstudy:post_user:edit')}]];
        var removeFlag = [[${@permission.hasPermi('workstudy:post_user:remove')}]];
        var statusDatas = [[${@dict.getType('workstudy_post_user_status')}]];
        var apprFlag = [[${@permission.hasPermi('workstudy:post_user:appr')}]];
        var apprFlag2 = [[${@permission.hasPermi('workstudy:post_user:appr2')}]];
        var prefix = ctx + "workstudy/post_user";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                apprUrl: prefix + "/appr/{id}",
                apprUrl2: prefix + "/appr2/{id}",
                modalName: "学生申请岗位",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'postUserId',
                    title: '学生申请岗位id',
                    visible: false
                },

                    {
                        title: '学生',
                        formatter: function(value, row, index) {
                            return row.userName+"("+row.loginName+")";
                        }
                    },
                    {
                        field: 'postName',
                        title: '岗位'
                    },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'applrContent',
                    title: '申请理由'
                },
                {
                    field: 'applrTime',
                    title: '申请时间'
                },
                {
                    field: 'approveBy',
                    title: '学生处'
                },
                {
                    field: 'approveContent',
                    title: '学生处审批理由'
                },
                {
                    field: 'approveTime',
                    title: '学生处审批时间'
                },
                {
                    field: 'approveEndBy',
                    title: '用人单位'
                },
                {
                    field: 'approveEndContent',
                    title: '用人单位审批理由'
                },
                {
                    field: 'approveEndTime',
                    title: '用人单位审批时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-primary btn-xs ' + apprFlag + '" href="javascript:void(0)" onclick="appr(\'' + row.postUserId + '\',\''+row.status + '\')" shiro:hasPermission="workstudy:post_user:appr"><i class="fa fa-check"></i>学生处审核</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + apprFlag2 + '" href="javascript:void(0)" onclick="appr2(\'' + row.postUserId + '\',\''+row.status + '\')" shiro:hasPermission="workstudy:post_user:appr2"><i class="fa fa-check"></i>用人单位审核</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="edit(\'' + row.postUserId + '\',\''+row.status + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="remove(\'' + row.postUserId + '\',\''+row.status + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        // 审核信息
        function appr(id,status) {
            table.set();
            if(status!=0){
                $.modal.alertWarning("该申请岗位已审批，不可审批!");
                //return;
            }
            var url = table.options.apprUrl.replace("{id}", id);
            $.modal.open("审核" + table.options.modalName, url);
        }
        // 审核信息
        function appr2(id,status) {
            table.set();
            if(status!=1){
                $.modal.alertWarning("该申请岗位学生处未通过审批，不可审批!");
                return;
            }
            var url = table.options.apprUrl2.replace("{id}", id);
            $.modal.open("审核" + table.options.modalName, url);
        }
        // 修改信息
        function edit(id,status) {
            table.set();
            if(status!=0){
                $.modal.alertWarning("该申请岗位已审批，不可编辑!");
                return;
            }
            $.modal.open("修改" + table.options.modalName, $.operate.editUrl(id));
        }
        // 删除信息
        function remove(id,status) {
            table.set();
            if(status!=0){
                $.modal.alertWarning("该申请岗位已审批，不可删除!");
                return;
            }
            $.modal.confirm("确定删除该条" + table.options.modalName + "信息吗？", function() {
                var url = $.common.isEmpty(id) ? table.options.removeUrl : table.options.removeUrl.replace("{id}", id);
                if(table.options.type == table_type.bootstrapTreeTable) {
                    $.operate.get(url);
                } else {
                    var data = { "ids": id };
                    $.operate.submit(url, "post", "json", data);
                }
            });
        }
    </script>
</body>
</html>